#!/bin/bash

NFS_SERVER_IP=${1:-"192.168.0.170"}
ENVID=${2:-"6279bb"}
STUID=${3:-"18965562230,189000000"}

if [[ -z "${NFS_SERVER_IP}" ]]; then
    echo '{\"status\":1,msg:\"nfs ip is empty\"}'
    exit 0
fi

ssh root@$NFS_SERVER_IP 'bash -s' << ENDSSH
    cd /nfs/k8s
    if [ -d "default-vmsnapshot-$ENVID-pvc" ]; then
        for id in $(echo $STUID | sed "s/,/ /g")
        do
            cp -rf default-vmsnapshot-$ENVID-pvc/. default-vm\${id}-$ENVID-pvc
            ls
        done
    fi
ENDSSH
exit